std::match_results

From Cppreference

Jump to: navigation, search
Defined in header <regex>

template<

    class BidirectionalIterator,
    class Allocator = std::allocator<std::sub_match<BidirectionalIterator>>

> class match_results;
(C++11 feature)

The class template match_results holds a collection of character sequences that represent the result of a regular expression match.

Several specializations for common character sequence types are provided:

Defined in header <regex>
Type Definition
cmatch match_results<const char*>
wcmatch match_results<const wchar_t*>
smatch match_results<std::string::const_iterator>
wsmatch match_results<std::wstring::const_iterator>

Contents

[edit] Member types

Member type Definition
allocator_type Allocator
value_type std::sub_match<BidirectionalIterator>
const_reference const value_type&
reference const_reference
const_iterator implementation defined
iterator const_iterator
difference_type std::iterator_traits<BidirectionalIterator>::difference_type
size_type std::allocator_traits<Allocator>::size_type
char_type std::iterator_traits<BidirectionalIterator>::value_type
string_type std::basic_string<char_type>

[edit] Member functions

(constructor)
constructs the object
(public member function)
(destructor)
destructs the object
(public member function)
get_allocator
returns the associated allocator
(public member function)
State
ready

(public member function)
Size
empty
checks if nothing was matched
(public member function)
size
returns one the number of matches, or 0
if *this does not represent a successful match
(public member function)
max_size
returns maximum possible number of sub-matches
(public member function)
Element access
length
returns the length of the particular sub-match
(public member function)
position
returns the position of the first character of the particular sub-match
(public member function)
str
returns the sequence of characters for the particular sub-match
(public member function)
operator[]
returns an sub_match defining particular sub-match
(public member function)
prefix
returns sub-sequence between the beginning of the sequence and the beginning of the particular sub-match
(public member function)
suffix
returns sub-sequence between the end of the particular sub-match and the end of the sequence
(public member function)
Iterators
begin
cbegin
returns iterator to the beginning of the list of sub-matches
(public member function)
end
cend
returns iterator to the end of the list of sub-matches
(public member function)
Format
format
formats match results for output
(public member function)
Modifiers
swap
swaps the contents
(public member function)